package com.chen.pojo.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 *
 * </p>
 *
 * @author 陈子安
 * @since 2023-11-30
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "User对象", description = "用表")
@TableName("users")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "用户ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    @ApiModelProperty(value = "邮箱")
    @Email
    private String email;

    //至少8个字符，包括至少1个小写字母、1个大写字母和1个数字
    @Pattern(regexp = "(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).{8,}")
    @ApiModelProperty(value = "密码")
    private String password;

    @NotBlank
    @ApiModelProperty(value = "名")
    private String firstName;

    @NotBlank
    @ApiModelProperty(value = "姓")
    private String lastName;

    @DecimalMin("0")
    @DecimalMax("1")
    @ApiModelProperty(value = "是否管理员 1 管理员  0 普通用户")
    private Integer isAdmin;

    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "更新时间")
    private LocalDateTime updatedAt;

    @ApiModelProperty(value = "是否禁用")
    private Integer disabled;

    @ApiModelProperty(value = "禁用时间")
    private LocalDateTime disabledAt;

    @ApiModelProperty(value = "是否可删除   被用 30 天以后才能被删除")
    private Boolean canBeDeleted;


}
